package com.test.daily.leetcode.y2021.m10.day1010;

/**
 * arrangeCoins
 *
 * @author Tom on 2021/10/10
 */
public class Code01_ArrangeCoins {
    public static void main(String[] args) {
        for (int i = 1804289382; i <= 1804289383; i++) {
            System.out.println("count:"+i+" level:"+arrangeCoins(i));
        }

    }
    public static int arrangeCoins(int n) {
        // 8 * n已经就是long类型了, 不然容易产生溢出
        return (int) ((Math.sqrt((long)8 * n + 1) - 1)/2);
    }
}
